<?php class CommandLineOptionLogLevel extends CommandLineOption {
	protected static $Levels = array (
		LOG_EMERG   => 'emerg',
		LOG_ALERT   => 'alert',
		LOG_CRIT    => 'crit',
		LOG_ERR     => 'err',
		LOG_WARNING => 'warning',
		LOG_NOTICE  => 'notice',
		LOG_INFO    => 'info',
		LOG_DEBUG   => 'debug',
	);
	protected function Usage () {
		if (strlen ($this->Default)) {
			if (array_key_exists ($this->Default, self::$Levels)) {
				$Default = '"'.self::$Levels [$this->Default].'"';
			} else {
				$Default = 'unknown';
			}
		} else {
			$Default = 'empty';
		}
		return ($this->Usage." (default: $Default)");
	}
	public function Set ($Value) {
		$this->Explicit = TRUE;
		if (is_array ($Value)) {
			$Value = end ($Value);
		}
		if (FALSE !== $Value) {
			if (! array_key_exists ($Value, self::$Levels)) {
				if (defined ($Level = 'LOG_'.strtoupper ($Value))) {
					$this->Value = constant ($Level);
				} else {
					throw new X_CommandLineOptionLogLevel (implode (', ', self::$Levels));
				}
			} else {
				$this->Value = $Value;
			}
		} else {
			$this->Explicit = FALSE;
		}
		return ($this->Value);
	}
}
class X_CommandLineOptionLogLevel extends Exception {}
?>